package net.oschina.app;

import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;

import com.robotium.solo.Solo;

/**
 * Created by Administrator on 2017/1/5.
 */

public class SoloWrap {

    private Solo solo;

    public SoloWrap(Solo solo){
        this.solo = solo;
    }

    public void clearEditText(EditText editText){
        solo.clearEditText(editText);
        Log.i("oschina", "清空文本框内容");
    }

    public void clickOnImage(int index){
        solo.clickOnImage(index);
        Log.i("oschina", "点击第"+index+"张图片");
    }

    public void clickOnText(String text){
        solo.clickOnText(text);
        Log.i("oschina", "点击文本："+text);
    }

    public void clickOnView(View view){
        solo.clickOnView(view);
        Log.i("oschina", "点击空间"+view);
    }

    public void enterText(EditText editText,String text){
        solo.enterText(editText,text);
        Log.i("oschina", "在文本框"+editText+"中输入"+text);
    }

    public String getWebUrl(){
        String url = solo.getWebUrl();
        Log.i("oschina", "当前url是"+url);
        return url;
    }

    public void goBack(){
        solo.goBack();
        Log.i("oschina", "返回上级页面");
    }

    public Boolean searchText(String text){
        Boolean isexistText = solo.searchText(text);
        Log.i("oschina", "文本"+text+isexistText+"存在");
        return isexistText;
    }

    public void sleep(int time){
        solo.sleep(time);
        Log.i("oschina", "等待"+time/1000+"s");
    }

    public void takeScreenshot(String name){
        solo.takeScreenshot(name);
        Log.i("oschina", "截图后把图片命名为"+name);
    }

    public void unlockScreen(){
        solo.unlockScreen();
        Log.i("oschina", "解锁");
    }

    public View getView(String id){
        try {
            Log.i("oschina", "获取控件"+id);
            return solo.getView(id);
        }catch (Exception e){
            Log.i("oschina", "没有找到控件");
            return null;
        }

    }

    public void scrollToBottom() {
        solo.scrollToBottom();
        Log.i("oschina", "一直滚动到底部");
    }

    public void scrollToTop() {
        solo.scrollToTop();
        Log.i("oschina", "一直滚动到顶部");
    }


}
